
var express = require('express')
var app = express()
app.use(express.static('z_static'))
// 第三步骤：设置接口，处理post请求的中间件
app.use(express.json())
app.use(express.urlencoded({extended:false}))
// 定义返回给客户端的数据
var arr = [
    {email:'12333443@qq.com',name:'张三',phone:'13345678833',pass:'1234',ingroup:'测试组',admin:true,status:true},
    {email:'12333443@qq.com',name:'张三',phone:'13345678844',pass:'1234',ingroup:'开发组',admin:true,status:true},
    {email:'12333443@qq.com',name:'张三',phone:'13345678855',pass:'1234',ingroup:'实验组',admin:true,status:true},
    {email:'12333443@qq.com',name:'张三',phone:'13345678866',pass:'1234',ingroup:'测试组',admin:true,status:false},
    {email:'12333443@qq.com',name:'张三',phone:'13345678877',pass:'1234',ingroup:'编辑组',admin:true,status:true},
    {email:'12333443@qq.com',name:'张三',phone:'13345678888',pass:'1234',ingroup:'开发组',admin:true,status:true},
    {email:'12333443@qq.com',name:'张三',phone:'13345678899',pass:'1234',ingroup:'测试组',admin:true,status:false}

]
// 设置接口：
app.get('/user/list',(req,res)=>{
    console.log('收到客户端请求get');
    var {page,count} = req.query
    console.log(page,count);
    res.send({code:200,msg:'请求成功', arr})
})
app.post('/user/login',(req,res)=>{
    console.log('来自客户端的请求post');
    console.log(req.body);
    res.send({code:200, msg:'登录成功'})
})
app.listen(8080)